﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MINERP.COM
{
    public class BlanceOprationRecord
    {
        static string filePath = Environment.CurrentDirectory + @"\BlanceOperationRecord.log";

        public static bool CreateLogFile()
        {
            try
            {
                if (!File.Exists(filePath))
                {
                    File.Create(filePath);            
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
                throw ex;             
            }
        }

        public static int WriteLog(StringBuilder sb)
        {
            int result = 0;
            StreamWriter sw =null;

            using ( sw = new StreamWriter(filePath, true))
            {

                try
                {
                    sw.WriteLine(sb.ToString());
                    sw.Close();
                    return result;
                }                
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    sw.Close();
                }
            }
           

             
        }

    }
}
